package uk.co.q3c.deplan.server.unit.dao;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;
import javax.persistence.Transient;

import uk.co.q3c.deplan.client.domain.AbstractDomainObject;
import uk.co.q3c.deplan.client.domain.DomainKind;
import uk.co.q3c.deplan.client.domain.DomainObject;
import uk.co.q3c.deplan.client.domain.resource.PersistenceReferenceException;
import uk.co.q3c.deplan.client.service.ServiceFactory;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Indexed;
import com.googlecode.objectify.annotation.Serialized;
import com.googlecode.objectify.annotation.Unindexed;

@Unindexed
@Cached(expirationSeconds = 600)
public class ComplexDomainObject extends AbstractDomainObject implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -9025765573561212405L;
	public static final int classId = 2000;
	@Id
	private Long keyId;
	@Transient
	private transient ServiceFactory connection;
	@Indexed
	private int intValue;

	@Serialized
	private SimpleDomainObject simple;

	public ComplexDomainObject() {
		super();
	}

	public ComplexDomainObject(int intValue) {
		super();
		this.intValue = intValue;
	}

	public int getIntValue() {
		return intValue;
	}

	public void setIntValue(int intValue) {
		this.intValue = intValue;
	}

	public SimpleDomainObject getSimple() {
		return simple;
	}

	public void setSimple(SimpleDomainObject simple) {
		this.simple = simple;
	}

	// public String getEncodedKey() {
	// return encodedKey;
	// }

	/**
	 * @return the discarded
	 */
	public boolean isDiscarded() {
		return discarded;
	}

	/**
	 * @param discarded
	 *            the discarded to set
	 */
	@Override
	public void setDiscarded(boolean discarded) {
		this.discarded = discarded;
	}

	@Override
	public void dereference() {
		// TODO Auto-generated method stub

	}

	@Override
	public Date getDiscardedDate() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setDiscardedDate(Date discardedDate) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean getDiscarded() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void setConnection(ServiceFactory connection) {
		this.connection = connection;
	}

	@Override
	public void afterLoad(ServiceFactory connection) {
		this.connection = connection;
	}

	@Override
	public ServiceFactory getConnection() {
		return connection;
	}

	@Override
	public DomainKind getKind() {
		return DomainKind.ComplexDomainObject;
	}

	public Long getKeyId() {
		return keyId;
	}

	@Override
	public Key<? extends DomainObject> getKey() throws PersistenceReferenceException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setKeyId(Long keyId) {
		// TODO Auto-generated method stub

	}
}
